<?php
//ini_set("display_errors" , 1);
ini_set('max_execution_time',10000);
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('xl_builder' , false);  
my_component_load('list_kalender' , false);   
my_component_load('a_control' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$tanggal = isset($_GET['tanggal']) ? $_GET['tanggal'] : "";  
$field = isset($_GET['field']) ? $_GET['field'] : "";  
$value = isset($_GET['value']) ? $_GET['value'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0; 
$periode_id = isset( $_GET['periode_id'] ) ? $_GET['periode_id']:   get_periode_absen();;
$karyawan_id = isset( $_GET['karyawan_id'] ) ? $_GET['karyawan_id']:  0; 

$sc_status_absen_id=isset($_GET['sc_status_absen_id']) ? $_GET['sc_status_absen_id'] : 0;  
$sc_kelompok_shift_id=isset($_GET['sc_kelompok_shift_id']) ? $_GET['sc_kelompok_shift_id'] : 0;  

$modulname = "Personalia _BN_ Waktu Kerja _BN_ Realisasi harian";

load_facebox_script();
if($_SERVER['REQUEST_METHOD'] == "POST"){
	if($task == 'upload_schedule_page'){
		upload_exception();
		generate_my_web("Uploaded!!!", $pagename ,"plain.php");
		exit;
	}else{
		submit_ubah_jadwal_wk($kid);
		generate_my_web("Updated!!!", $pagename ,"plain.php");
		exit;
	}
}else{
	if($task == 'upload_schedule'){ 
		$periode_data = my_get_data_by_id('pr_periode','periode_id',$periode_id);
		facebox_page( 'index.php?com='.$_GET['com'].'&task=upload_schedule_page', "Upload jadwal kerja periode ".$periode_data['dari']." s/d ". $periode_data['sampai'] ,170);
	}elseif($task == 'edit_wk_page'){ 
		$content =form_set_waktu($kid);//form_spl_create($id); 
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}elseif($task == 'excel_data'){
		$periode = my_get_data_by_id('pr_periode','periode_id',$periode_id);
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=jadwal_karyawan_".date('d-m-Y',strtotime($periode['dari']))."_".date('d-m-Y',strtotime($periode['sampai']))."_".rand(1000,9999) .".xls");
		echo excel_jadwal_karyawan();
		exit;
	
	}elseif($task == 'export_excel'){ 
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=kehadiran.xls");
		echo list_karyawan_realisasi_excel();
		exit;

	}elseif($task == 'export_excel_karyawan'){ 
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=kehadiran_per_karyawan.xls");
		echo excel_absen_per_person($karyawan_id);
		exit;
		
	}elseif($task == 'export_excel_allkaryawan'){ 
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=kehadiran_semua_karyawan.xls");
		 
		echo excel_absen_all_person( );
		exit;
		
	}elseif($task == 'list_detail'){
		$pagename =$modulname." _BN_ Detail";
		$content =  detail_realisasi_karyawan($karyawan_id);
	}else{	
		$pagename = $modulname;
		$content = list_karyawan_realisasi() ;	 
	}
}
generate_my_web($content, $pagename );